
{extend name='public/window' /}

{block name="content"}
<style>
    .layui-upload-drag {
        position: relative;
        padding: 10px;
        border: 1px dashed #e2e2e2;
        background-color: #fff;
        text-align: center;
        cursor: pointer;
        color: #999;
        border-radius: 50%;
    }
    .layui-form-label{
        width: 110px;
    }
    .layui-input-block{
        width: 85%;
        margin-left: 146px;
    }
    .layui-input, .layui-textarea {
        display: block;
        width: 80%;
        padding-left: 10px;
    }
    /* .layui-form-select {
        position: absolute;
        right: 165px;
        top: 50%;
        } */
    .layui-form-select .layui-edge {
        position: absolute;
        right: 170px !important;
        top: 50%;
    }
    .layui-form-select dl {
        min-width: 80% !important;
    }
    .layui-form-label {
        width: 116px !important;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="form">
                {if isset($info.id)}
                <input type="hidden" name="id" value="{$info.id}">
                {/if}
                <input type="hidden" name="__token__" id="token" value="{:token()}"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">设备类型 </label>
                    <div class="layui-input-block" >
                        <select name="type"  lay-filter="type" id="type"  lay-verify="required" >
                            <option value="">请选择</option>
                            <option value="1" >智能电表</option>
                            <option value="2" >智能水表</option>
                            <option value="3" >普通电表</option>
                            <option value="4" >普通水表</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">使用类型 </label>
                    <div class="layui-input-block" >
                        <select name="use_type"  lay-filter="use_type" id="use_type"  >
                            <option value="">请选择</option>
                            <option value="1" >写字楼自用</option>
                            <option value="2" >写字楼公区</option>
                            <option value="3" >写字楼商户</option>
                            <option value="4" >商场自用</option>
                            <option value="5" >商场公区</option>
                            <option value="6" >商场商户</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">所属位置</label>
                    <div class="layui-input-block" >
                        <select name="address"  lay-filter="address" id="address">
                            <option value="">请选择</option>
                            <option value="正铺" >正铺</option>
                            <option value="仓库" >仓库</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否特殊用表</label>
                    <div class="layui-input-block" >
                        <select name="is_sole"  lay-filter="is_sole" id="is_sole">
                            <option value="">请选择</option>
                            <option value="0" >否</option>
                            <option value="1" >是</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否总表</label>
                    <div class="layui-input-block" >
                        <select name="is_normal"  lay-filter="is_normal" id="is_normal">
                            <option value="">请选择</option>
                            <option value="1" >否</option>
                            <option value="2" >是</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item nolins" >
                    <label class="layui-form-label">设备编号 </label>
                    <div class="layui-input-block">
                        <input type="text" name="pointId"   autocomplete="off"
                               placeholder="请输入编号" class="layui-input"  >
                    </div>
                </div>
                <div class="layui-form-item nolins" >
                    <label class="layui-form-label">设备名称 </label>
                    <div class="layui-input-block">
                        <input type="text" name="pointName"   autocomplete="off"
                               placeholder="请输入表号" class="layui-input"  >
                    </div>
                </div>
                <div class="layui-form-item nolins">
                    <label class="layui-form-label">倍率 </label>
                    <div class="layui-input-block">
                        <input type="text" name="rate"  autocomplete="off"
                               placeholder="请输入倍率" class="layui-input" id="name_edit" value="1">
                    </div>
                </div>
                <div class="layui-form-item nolins">
                    <label class="layui-form-label">装表读数 </label>
                    <div class="layui-input-block">
                        <input type="text" name="initial_degrees"  lay-verify="required"  autocomplete="off"
                               placeholder="请输入装表读数" class="layui-input" id="company_edit">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">商户 </label>
                    <div class="layui-input-block" >
                        <select name="merchant_id"   lay-search="">
                            <option value="0">请选择</option>
                            {volist name="merchant_list" id="t"}
                            {if empty($t.name)||$t.name=='-'}
                            <option value="{$t.id}" >{$t.company} - {$t.code}-{$t.biz_state}-{$t.positions_code}</option>
                            {else/}
                            <option value="{$t.id}" >{$t.name} - {$t.code}-{$t.biz_state}-{$t.positions_code}</option>
                            {/if}
                            {/volist}

                        </select>
                    </div>
                </div>

                <div class="layui-form-item layui-layout-admin " style="width: 100%">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0px;text-align: center;">
                            <button class="layui-btn check" lay-submit="" lay-filter="check">检测</button>
                            <button id="tijiao"   class="layui-btn " lay-submit="" lay-filter="add">{:__('Submit')}</button>
                            <button type="reset" class="layui-btn layui-btn-primary">{:__('Reset')}</button>
                        </div>
                    </div>
                </div>

            </form>
        </div>
    </div>
</div>


<script>
    layui.use(['element', 'form', 'jquery','lucky','upload','laydate','xmSelect'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var lucky=layui.lucky;
        laydate.render({
            elem: '#start_time'
            ,type: 'date',
            trigger: 'click'
        });
        laydate.render({
            elem: '#end_time'
            ,type: 'date',
            trigger: 'click'
        });
        form.on('select(type)', function(data){
            var  type = data.value;
            console.log(type)
            if(type==3||type==4){
                console.log(1)
                $('#tijiao').attr("disabled",false);
                $('#tijiao').removeClass("layui-btn-disabled");//隐藏
                $('.check').hide();
            }else{
                $('.check').show();
                $('#tijiao').attr("disabled",true);
                $('#tijiao').addClass("layui-btn-disabled");//隐藏
            }
        });
        var info = {:json_encode($info)};
        form.val("form",info);
        form.on('submit(add)', function (data) {
            lucky.FormSubmit("{:url('add')}",data.field,true);
            return false;
        });
        form.on('submit(check)', function (data) {
            layer.msg('设备编号检验中....');
            $.ajax({
                url: "{:url('check')}",
                method: "post",
                data: data.field,
                dataType: "json",
                success: function (data) {
                   var data = JSON.parse(data)
                    if(data.code==-1){
                        layer.msg(data.msg);
                    }else {
                        $('#tijiao').removeAttr("disabled");
                        $('#tijiao').removeClass("layui-btn-disabled");
                        layer.msg(data.msg);
                    }

                }
            });
            return false
        });
        //检测表号
        function check(){

        }
    })
</script>

{/block}

